# 打开一个不存在的文件
# f = open("D:/Users/李健奇/OneDrive/桌面/Python/基础/文件操作/追加.txt","a",encoding="UTF-8")
# f.write("李健奇，辽宁工业大学，软件工程")
# f.flush()
# f.close()

# 打开存在的文件
# f = open("D:/Users/李健奇/OneDrive/桌面/Python/基础/文件操作/追加.txt","a",encoding="UTF-8")
# f.write("Python 大数据方向")
# f.flush()
# f.close()

# 数据可视化
f1 = open("D:/Users/李健奇/OneDrive/桌面/Python/基础/文件操作/bill.txt","r",encoding="UTF-8")
f2 = open("D:/Users/李健奇/OneDrive/桌面/Python/基础/文件操作/bill.txt.bak","w",encoding="UTF-8")
for line in f1:
    line = line.strip()                     # 去除前后空格以及换行符
    if line.split(",")[-1] != '测试':   # 切分成了列表，按照下标索引找到最后一位进行判断
        f2.write(line)
        f2.write("\n")                       # 需要手动写入换行符
    continue
f1.close()
f2.close()
